// report/report_generator.rs
use crate::stats::stats_collector::Stats;
use std::fs::File;
use std::io::{self, Write};

pub fn generate_report(stats: &Stats) -> io::Result<()> {
    let mut file = File::create("performance_report.txt")?;

    writeln!(file, "Performance Test Report")?;
    writeln!(file, "==========================")?;
    writeln!(file, "Total Requests: {}", stats.total_requests)?;
    writeln!(file, "Successful Requests: {}", stats.success_requests)?;
    writeln!(file, "Failed Requests: {}", stats.failure_requests)?;
    writeln!(file, "Average Response Time: {:.2} ms", stats.average_response_time())?;

    Ok(())
}
